package com.mayikt;

/**
 * @ClassName Test003
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test003 extends Thread {
    private int count = 0;

    @Override
    public void run() {
        while (count < 10000) {
            create();
        }
    }

    private synchronized void create() {
        count++;
        System.out.println(Thread.currentThread().getName() + "," + count);
    }

    public static void main(String[] args) throws InterruptedException {
        Long startTime=System.currentTimeMillis();
        Test003 test003 = new Test003();
        Thread t1 = new Thread(test003);
        Thread t2 = new Thread(test003);
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        Long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }
}
